package com.oba.king.datalib.deliverytype;

import java.util.Date;

import com.oba.base.dao.DBDataModel;

/**
 * 
 * @author 大饼
 * 发货方式管理
 */
public class DeliveryTypeBean extends com.oba.base.service.BaseBean<DeliveryType, DeliveryTypeService>{
      private DBDataModel deliveryTypeData = DBDataModel.create();
      private DeliveryType deliveryType;
      
      private String deliveryTypeName;
      
      private boolean showdeliveryType;
      
      public String doFind(){
    	  deliveryTypeData.find(getService().getDao().findAll());
    	  return null;
    	  
      }
      
      public void findByDeliveryName(){
    	  deliveryTypeData.find(getService().getDao().findByDeliveryName(deliveryTypeName));
      }
      
      public void clearDeliveryType(){
    	  deliveryTypeName=null;
      }
      
      

  	
  	
	public void doAddRow(){
  		deliveryType=new DeliveryType();
  		deliveryType.setNewBo(true);
  		deliveryType.setCreateDate(new Date());
  		deliveryType.setInActive("Y");
  		showdeliveryType=true;
  	}
  	
  	public void doDeleteRow() {
  		if(deliveryTypeData.isRowAvailable()) {
  			deliveryType = (DeliveryType) deliveryTypeData.getRowData();
  			getService().del(deliveryType);
  			doFind();
  		}
  	}
  	
  	public void doEditRow() {
  		if(deliveryTypeData.isRowAvailable()) {
  			deliveryType = (DeliveryType) deliveryTypeData.getRowData();
  			deliveryType.setUpdateDate(new Date());
  			showdeliveryType = true;
  			doFind();
  		}
  	}
  	
  	public void closeShowEdit() {
  		showdeliveryType = false;
  	}
  	
  	public void doSaveRow() {

  		getService().save(deliveryType);
  		showdeliveryType = false;
  		doFind();
  	}
  	

	@Override
	public void init() {
		deliveryTypeData.find(getService().getDao().findAll());
		deliveryType =new DeliveryType();
		showdeliveryType = false;
	}
	
	
	public DBDataModel getDeliveryTypeData() {
		return deliveryTypeData;
	}


	public void setDeliveryTypeData(DBDataModel deliveryTypeData) {
		this.deliveryTypeData = deliveryTypeData;
	}


	public DeliveryType getDeliveryType() {
		return deliveryType;
	}


	public void setDeliveryType(DeliveryType deliveryType) {
		this.deliveryType = deliveryType;
	}


	public String getDeliveryTypeName() {
		return deliveryTypeName;
	}


	public void setDeliveryTypeName(String deliveryTypeName) {
		this.deliveryTypeName = deliveryTypeName;
	}


	public boolean isShowdeliveryType() {
		return showdeliveryType;
	}


	public void setShowdeliveryType(boolean showdeliveryType) {
		this.showdeliveryType = showdeliveryType;
	}



}
